package com.yl.immodule.fragment

import androidx.fragment.app.activityViewModels
import com.alibaba.android.arouter.facade.annotation.Route
import com.camera.base.dialog.NumberPickerDialog
import com.camera.base.v.BaseFragment
import com.camera.routemodule.RouterPath
import com.yl.immodule.R
import com.yl.immodule.databinding.FragmentChannelSettingsBinding
import com.yl.immodule.fragment.model.ChannelSettingViewModel

/**
 * 对讲设置Fragment
 */
@Route(path = RouterPath.path.channel_settings_fragment)
class ChannelSettingsFragment : BaseFragment<FragmentChannelSettingsBinding>() {
    val TAG = ChannelSettingsFragment::class.java.simpleName
    private val viewModel: ChannelSettingViewModel by activityViewModels()
    private var mNumberPickerDialog:NumberPickerDialog? =null
    override fun getLayoutId(): Int {
        return R.layout.fragment_channel_settings
    }

    override fun initView() {

    }

    override fun loadData(isRefresh: Boolean) {
        mBinding.viewModel = viewModel
        viewModel.showNumberPickerDialog.observe(this) { it ->
            if (it.value2 && it.value3 != null){
                val titleDialog = ""
//                val titleDialog = when (it.value1){
//                    R.id.btn_video_record_segmented_set -> this.getString(R.string.video_record_segmenteds)
//                    else -> ""
//                }
                mNumberPickerDialog = NumberPickerDialog(requireContext(), titleDialog, it.value3!!, { position,vlaue ->
                    when (it.value1){
                        R.id.aec -> viewModel.saveAec(position)
                        R.id.agc -> viewModel.saveAgc(position)
                        R.id.ng -> viewModel.saveNg(position)
                    }
                })
                mNumberPickerDialog?.show()
            }else{
                mNumberPickerDialog?.dismiss()
            }
        }
    }

} 